#include "syscall.h"

int lock;
int condition;
void test4_main()
{
	WriteFormat("----------Test Case IV---------\n",33,0,0);
	WriteFormat("/*Test Function of Remote Condition */\n",40,0,0);
	
	WriteFormat("4-0 Prepare Lock to be used    \n",33,0,0);
	lock = RemoteCreateLock("TestConditionLock1",18);
	WriteFormat("    Lock Created, handle is %d \n",38,&lock,1);
	
	WriteFormat("4-1 CreateCondition            \n",33,0,0);
	condition = RemoteCreateCondition("TestCondition1",14);
	WriteFormat("    Condition Created, handle is %d \n",38,&lock,1);
	WriteFormat("4-2 Broadcast Condition        \n",33,0,0);
	WriteFormat("    Make 4 clients to wait in Condition %d \n",45,&condition,1);
	WriteFormat("    Main client now broadcast Condition %d \n",45,&condition,1);
	WaitInput();
	RemoteAcquireLock(lock);
	RemoteBroadcastCondition(condition,lock);
	RemoteReleaseLock(lock);
	WriteFormat("    Wait for other clients to end \n",36,0,0);
	WaitInput();
	RemoteDestroyCondition(condition);
	RemoteDestroyLock(lock);
	WriteFormat("----------  Test end  ----------\n",34,0,0);
}
int main()
{
	test4_main();
}
